# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ukui-control-center
pkgver=3.0.4
pkgrel=9
pkgdesc="Utilities to configure the UKUI desktop"
arch=('loong64' 'x86_64')
license=('GPL')
url="https://github.com/ukui/ukui-control-center"
groups=('ukui')
depends=('bluez-qt5' 'ddcutil' 'kconfig5' 'kconfigwidgets5' 'ki18n5' 'kscreen'
         'kwidgetsaddons5' 'libpwquality' 'lsb-release' 'peony' 'qt5-quickcontrols' 'ukui-interface'
         'ukui-panel' 'ukui-media' 'ukui-menus' 'ukui-power-manager' 'ukui-screensaver'
         'ukui-settings-daemon' 'upower' 'libcanberra')
makedepends=('boost' 'qt5-tools')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ukui/ukui-control-center/archive/v$pkgver.tar.gz"
        6.patch
        libkscreen-5.27.patch
        ddcutil-2.patch)
sha512sums=('f751502d66a36d8a6fe0199ec4408c3c371923c9a9b1e722f75bff66090f3b6eac18df2c8fd5b7c4d223a7938f491e4b89a91636cf15944574ecdeb43b995f4c'
            'b15fc2f32fac0fbae3bf30d9cc19c78375bd50c35815d540c79ac9a7ba561b52ca599c0385826529603146f7a368045f1a861b5173f2538b226376e9f4cd9129'
            'cadf51c25f2cfdb236507366b644f6b1ea371b812664190f09f3e0ac2c9f76c29759cdb01492b9847a3327d123f711ab383dc2967c926c8637a043d8b76d1037'
            'f20a380109c4786c77c44eaf402bcc0a1af1bd3d2af77a6a24cfdbabbecf003ea148bf61fd09ebaecf2cb450048f3eb1bc46b64decb393e2d0682287c58e912e')

prepare() {
  cd ukui-control-center-$pkgver

  # Fix format-security
  # https://github.com/ukui/ukui-control-center/pull/6
  patch -Np1 -i ../6.patch

  # QSysInfo::productVersion() returns "unknown" on Arch
  #TODO: sed -i 's/productVersion/prettyProductName/' plugins/messages-task/about/about.cpp

  sed -i 's|systemd_service.path = /lib/systemd/system|systemd_service.path = /usr/lib/systemd/system|' group-manager-server/group-manager-server.pro
  sed -i 's|gio-unix-2.0|glib-2.0|' plugins/account/userinfo/giodbus.cpp

  # Fix build with libkscreen 5.27
  sed -e 's|c++11||' -i plugins/system/display/display.pro -i plugins/system/touchscreen/touchscreen.pro
  patch -p1 -i ../libkscreen-5.27.patch

  # Fix build with ddcutil 2
  patch -p1 -i ../ddcutil-2.patch
}

build() {
  cd ukui-control-center-$pkgver
  qmake-qt5 PREFIX=/usr
  make
}

package() {
  cd ukui-control-center-$pkgver
  make INSTALL_ROOT="$pkgdir" install

  install -Dm644 registeredQDbus/conf/com.control.center.qt.systemdbus.service -t "$pkgdir"/usr/share/dbus-1/system-services/
  install -Dm644 registeredQDbus/conf/com.control.center.qt.systemdbus.conf -t "$pkgdir"/usr/share/dbus-1/system.d/
}
